package com.myspace.backend.service.impl.user;

import com.myspace.backend.mapper.UserMapper;
import com.myspace.backend.pojo.User;
import com.myspace.backend.service.user.UserListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class UserListServiceImpl implements UserListService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<Map<String, String>> getUserlist() {

        List<Map<String, String>> list = new ArrayList<>();

        for (int i = 1; i <= 10; i ++) {
            Map<String, String> map = new HashMap<>();
            User user = userMapper.selectById(i);
            map.put("id", user.getId().toString());
            map.put("username", user.getUsername());
            map.put("photo", user.getPhoto());
            map.put("followerCount", user.getFollowerCount().toString());
            list.add(map);
        }

        return list;
    }
}
